package com.imooc.poker_game_v2;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 整一副牌
 * 
 *  2 3 4 5 6 7 8 9 10 J Q K A
 *  黑 红 梅 方
 *
 */
public class Poker {
	private List<Card> cards = new ArrayList<Card>();
	
	public Poker() {
		// 创建牌
		createPoker();
		// 洗牌
		randomPoker();
	}
	
	/**
	 * 创建新牌
	 */
	private void createPoker() {
		System.out.println("-------创建扑克牌-------");
		String[] names = {
			"2", "3", "4", "5", "6",
			"7", "8", "9", "10", 
			"J", "Q", "K", "A",
		};
		String[] colors = {"黑", "红", "梅", "方"};
		
		for (int i = 0; i < names.length; i++) {
			for (int j = 0; j < colors.length; j++) {
				cards.add(new Card(i, j, names[i], colors[j]));
			}
		}
		System.out.println("----------扑克牌创建完毕!----------");
	}
	
	/**
	 * 洗牌
	 */
	private void randomPoker() {
		System.out.println("--------开始洗牌-------");
		Collections.shuffle(cards);
		System.out.println("--------洗牌洗牌-------");
	}
	
	/**
	 * 根据索引获取扑克牌
	 * @param index
	 * @return Card
	 */
	public Card get(int index) {
		return this.cards.get(index);
	}
	
	/**
	 * @return
	 * 获取扑克牌
	 */
	public int size() {
		return this.cards.size();
	}
	
	
}
